home *** CD-ROM | disk | FTP | other *** search
- head 4.0;
- access;
- symbols;
- locks; strict;
- comment @ * @;
-
-
- 4.0
- date 93.03.01.19.59.00; author davy; state Exp;
- branches;
- next 3.4;
-
- 3.4
- date 93.02.24.17.44.45; author davy; state Exp;
- branches;
- next 3.3;
-
- 3.3
- date 93.01.16.19.08.59; author davy; state Exp;
- branches;
- next 3.2;
-
- 3.2
- date 93.01.15.19.33.39; author davy; state Exp;
- branches;
- next 3.1;
-
- 3.1
- date 93.01.13.20.18.17; author davy; state Exp;
- branches;
- next 3.0;
-
- 3.0
- date 91.01.23.08.23.06; author davy; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 90.08.17.15.47.24; author davy; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 88.11.29.11.20.35; author davy; state Released;
- branches;
- next ;
-
-
- desc
- @NFSWATCH - monitor Network File System traffic on the network.
- @
-
-
- 4.0
- log
- @NFSWATCH Version 4.0.
- @
- text
- @#ifndef lint
- static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/netaddr.c,v 3.4 1993/02/24 17:44:45 davy Exp davy $";
- #endif
-
- #include "os.h"
-
- /*
- * netaddr.c - routines for working with network addresses.
- *
- * David A. Curry Jeffrey C. Mogul
- * Purdue University Digital Equipment Corporation
- * Engineering Computer Network Western Research Laboratory
- * 1285 Electrical Engineering Building 250 University Avenue
- * West Lafayette, IN 47907-1285 Palo Alto, CA 94301
- * davy@@ecn.purdue.edu mogul@@decwrl.dec.com
- *
- * $Log: netaddr.c,v $
- * Revision 3.4 1993/02/24 17:44:45 davy
- * Added -auth mode, changes to -proc mode, -map option, -server option.
- *
- * Revision 3.3 1993/01/16 19:08:59 davy
- * Corrected Jeff's address.
- *
- * Revision 3.2 1993/01/15 19:33:39 davy
- * Miscellaneous cleanups.
- *
- * Revision 3.1 1993/01/13 20:18:17 davy
- * Put in OS-specific define scheme, and merged in Tim Hudson's code for
- * SGI systems (as yet untested).
- *
- * Revision 3.0 1991/01/23 08:23:06 davy
- * NFSWATCH Version 3.0.
- *
- * Revision 1.2 90/08/17 15:47:24 davy
- * NFSWATCH Version 2.0.
- *
- * Revision 1.1 88/11/29 11:20:35 davy
- * NFSWATCH Release 1.0
- *
- */
- #include <sys/param.h>
- #include <netdb.h>
- #include <stdio.h>
-
- #include "nfswatch.h"
- #include "externs.h"
-
- /*
- * get_net_addrs - get network addresses of source and destination
- * hosts, along with official host names.
- */
- void
- get_net_addrs()
- {
- register int n;
- char *inet_ntoa();
- register char **cp;
- struct hostent *hp;
-
- /*
- * Look up the local host.
- */
- if ((hp = gethostbyname(myhost)) == NULL) {
- (void) fprintf(stderr, "%s: %s: unknown host.\n", pname,
- myhost);
- finish(-1);
- }
-
- /*
- * Save the official host name.
- */
- (void) strcpy(myhost, hp->h_name);
-
- /*
- * If one was specified, look up the destination host.
- * Otherwise, we can use what we have.
- */
- if (allflag) {
- (void) sprintf(dsthost, "all hosts");
- }
- else if (dstflag) {
- if ((hp = gethostbyname(dsthost)) == NULL) {
- (void) fprintf(stderr, "%s: %s: unknown host.\n", pname,
- dsthost);
- finish(-1);
- }
-
- /*
- * Save the official host name.
- */
- (void) strcpy(dsthost, hp->h_name);
- }
- else {
- /*
- * Host name is the same as the local
- * host.
- */
- (void) strcpy(dsthost, myhost);
- }
-
- /*
- * Copy destination host's network addresses.
- */
- n = 0;
- (void) bzero((char *) dstaddrs, MAXHOSTADDR * sizeof(u_long));
-
- for (cp = hp->h_addr_list; *cp != NULL; cp++) {
- if (n >= MAXHOSTADDR)
- break;
-
- (void) bcopy(*cp, (char *) &dstaddrs[n], hp->h_length);
- n++;
- }
-
- /*
- * If they specified a server host, get its addresses.
- */
- if (serverflag) {
- if ((hp = gethostbyname(serverhost)) == NULL) {
- fprintf(stderr, "%s: %s: unknown host.\n", pname,
- serverhost);
- finish(-1);
- }
-
- /*
- * Save the official host name.
- */
- (void) strcpy(serverhost, hp->h_name);
-
- /*
- * Copy the server's network addresses.
- */
- n = 0;
- (void) bzero((char *) serveraddrs, MAXHOSTADDR *
- sizeof(u_long));
-
- for (cp = hp->h_addr_list; *cp != NULL; cp++) {
- if (n >= MAXHOSTADDR)
- break;
-
- (void) bcopy(*cp, (char *) &serveraddrs[n],
- hp->h_length);
- n++;
- }
- }
-
- /*
- * If they didn't specify a source host,
- * we're done.
- */
- if (!srcflag)
- return;
-
- /*
- * Look up the source host.
- */
- if ((hp = gethostbyname(srchost)) == NULL) {
- (void) fprintf(stderr, "%s: %s: unknown host.\n", pname,
- srchost);
- finish(-1);
- }
-
- /*
- * Save the official host name.
- */
- (void) strcpy(srchost, hp->h_name);
-
- /*
- * Copy source host's network addresses.
- */
- n = 0;
- (void) bzero((char *) srcaddrs, MAXHOSTADDR * sizeof(u_long));
-
- for (cp = hp->h_addr_list; *cp != NULL; cp++) {
- if (n >= MAXHOSTADDR)
- break;
-
- (void) bcopy(*cp, (char *) &srcaddrs[n], hp->h_length);
- n++;
- }
- }
-
- /*
- * want_packet - determine if we're interested in a packet by examining
- * its source and destination addresses.
- */
- int
- want_packet(src, dst)
- u_long src, dst;
- {
- register int i, want;
-
- want = FALSE;
-
- /*
- * Check that the source or destination is the server.
- */
- if (serverflag) {
- for (i=0; (serveraddrs[i] != 0) && (i < MAXHOSTADDR); i++) {
- if (!bcmp((char *) &src, (char *) &serveraddrs[i],
- sizeof(u_long)) ||
- !bcmp((char *) &dst, (char *) &serveraddrs[i],
- sizeof(u_long))) {
- want = TRUE;
- break;
- }
- }
-
- if (want && allflag)
- thisdst = dst;
-
- return(want);
- }
-
- /*
- * Any source or destination is okay.
- */
- if (allflag) {
- thisdst = dst;
- return(TRUE);
- }
-
- /*
- * Check source address first.
- */
- if (srcflag) {
- for (i = 0; (srcaddrs[i] != 0) && (i < MAXHOSTADDR); i++) {
- if (!bcmp((char *) &src, (char *) &srcaddrs[i],
- sizeof(u_long))) {
- want = TRUE;
- break;
- }
- }
-
- /*
- * If it's not from our source, we
- * don't even need to check the destination.
- */
- if (!want)
- return(FALSE);
- }
-
- want = FALSE;
-
- /*
- * Check destination address.
- */
- for (i = 0; (dstaddrs[i] != 0) && (i < MAXHOSTADDR); i++) {
- if (!bcmp((char *) &dst, (char *) &dstaddrs[i],
- sizeof(u_long))) {
- want = TRUE;
- break;
- }
- }
-
- return(want);
- }
- @
-
-
- 3.4
- log
- @Added -auth mode, changes to -proc mode, -map option, -server option.
- @
- text
- @d2 1
- a2 1
- static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/netaddr.c,v 3.3 1993/01/16 19:08:59 davy Exp davy $";
- d18 3
- @
-
-
- 3.3
- log
- @Corrected Jeff's address.
- @
- text
- @d2 1
- a2 1
- static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/netaddr.c,v 3.2 1993/01/15 19:33:39 davy Exp davy $";
- d18 3
- d113 32
- d190 2
- d193 20
- a218 2
-
- want = FALSE;
- @
-
-
- 3.2
- log
- @Miscellaneous cleanups.
- @
- text
- @d2 1
- a2 1
- static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/netaddr.c,v 3.1 1993/01/13 20:18:17 davy Exp davy $";
- d13 1
- a13 1
- * 1285 Electrical Engineering Building 100 Hamilton Avenue
- d18 3
- @
-
-
- 3.1
- log
- @Put in OS-specific define scheme, and merged in Tim Hudson's code for
- SGI systems (as yet untested).
- @
- text
- @d2 1
- a2 1
- static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/netaddr.c,v 3.0 1991/01/23 08:23:06 davy Exp davy $";
- d5 2
- d11 5
- a15 5
- * SRI International Digital Equipment Corporation
- * 333 Ravenswood Avenue Western Research Laboratory
- * Menlo Park, CA 94025 100 Hamilton Avenue
- * davy@@erg.sri.com Palo Alto, CA 94301
- * mogul@@decwrl.dec.com
- d18 4
- a35 1
- #include "os.h"
- @
-
-
- 3.0
- log
- @NFSWATCH Version 3.0.
- @
- text
- @d2 1
- a2 1
- static char *RCSid = "$Header: /tmp_mnt/net/sparky.a/davy/system/nfswatch/RCS/netaddr.c,v 1.2 90/08/17 15:47:24 davy Exp Locker: davy $";
- d15 4
- a18 1
- * $Log: netaddr.c,v $
- d30 1
- @
-
-
- 1.2
- log
- @NFSWATCH Version 2.0.
- @
- text
- @d2 1
- a2 1
- static char *RCSid = "$Header: /tmp_mnt/net/sparky.a/davy/system/nfswatch/RCS/netaddr.c,v 1.1 88/11/29 11:20:35 davy Released Locker: davy $";
- d8 6
- a13 5
- * David A. Curry
- * SRI International
- * 333 Ravenswood Avenue
- * Menlo Park, CA 94025
- * davy@@itstd.sri.com
- d16 3
- @
-
-
- 1.1
- log
- @NFSWATCH Release 1.0
- @
- text
- @d2 1
- a2 1
- static char *RCSid = "$Header$";
- d9 4
- a12 5
- * Research Institute for Advanced Computer Science
- * Mail Stop 230-5
- * NASA Ames Research Center
- * Moffett Field, CA 94035
- * davy@@riacs.edu
- d14 4
- a17 1
- * $Log$
- d56 4
- a59 1
- if (dstflag) {
- d138 8
- @
-